package br.com.j7.jdesk.persistence.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Version;

@Entity
@NamedQueries( {@NamedQuery(name="serviceState",query="Select ss from ServicesStates ss"), 
			    @NamedQuery(name="serviceStateByCdState", query="from ServicesStates where cdServiceState = ?1")} )
public class ServicesStates implements Serializable{

	private static final long serialVersionUID = 1L;

	@Id
	private Integer idServiceState;
	@Column(nullable=true)
	private String cdServiceState;
	@OneToMany(mappedBy="serviceState", cascade=CascadeType.MERGE)
	private List<ServicesSituations> servicesSituations;
	@Version
	private Integer nrVersion;
	
	private String dsPathIcon;
	
	public ServicesStates() {
	}

	public Integer getIdServiceState() {
		return idServiceState;
	}

	public void setIdServiceState(Integer idServiceState) {
		this.idServiceState = idServiceState;
	}

	public String getCdServiceState() {
		return cdServiceState;
	}

	public void setCdServiceState(String cdServiceState) {
		this.cdServiceState = cdServiceState;
	}

	public List<ServicesSituations> getServicesSituations() {
		return servicesSituations;
	}

	public void setServicesSituations(List<ServicesSituations> servicesSituations) {
		this.servicesSituations = servicesSituations;
	}

	public String getDsPathIcon() {
		return dsPathIcon;
	}
	
	public void setDsPathIcon(String dsPathIcon) {
		this.dsPathIcon = dsPathIcon;
	}
	
	public Integer getNrVersion() {
		return nrVersion;
	}

	public void setNrVersion(Integer nrVersion) {
		this.nrVersion = nrVersion;
	}

	@Override
	public int hashCode() {
		return idServiceState;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ServicesStates other = (ServicesStates) obj;
		if (idServiceState == null) {
			if (other.idServiceState != null)
				return false;
		} else if (!idServiceState.equals(other.idServiceState))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return cdServiceState;
	}

}
